package com.kanq.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kanq.mapper.KanqAiPromptMapper;
import com.kanq.pojo.entity.KanqAiPrompt;
import com.kanq.service.KanqAiPromptService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KanqAiPromptServiceImpl extends ServiceImpl<KanqAiPromptMapper, KanqAiPrompt> implements KanqAiPromptService {

    @Resource
    private KanqAiPromptMapper KanqAiPromptMapper;

    @Override
    public String getByName(String name) {
        List<KanqAiPrompt> prompts = KanqAiPromptMapper.selectList(Wrappers.<KanqAiPrompt>lambdaQuery().eq(KanqAiPrompt::getIsDeleted, 0));
        for (KanqAiPrompt prompt : prompts) {
            if (prompt.getPromptName().equals(name)) {
                return prompt.getPromptContent();
            }
        }
        return "";
    }

    @Override
    public List<KanqAiPrompt> getPrompts() {
        return KanqAiPromptMapper.selectList(Wrappers.<KanqAiPrompt>lambdaQuery().eq(KanqAiPrompt::getIsDeleted, 0));
    }
}
